//
//  ExpressionButton.m
//  Comma
//
//  Created by liuchang on 15/1/26.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "ExpressionButton.h"

@implementation ExpressionButton

- (instancetype)initWithDictionary:(NSDictionary *)infoDic Frame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.infoDic = infoDic;
        [self setClipsToBounds:YES];
        UIButton * button = [UIButton buttonWithType:UIButtonTypeSystem];
        [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        [button setFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        NSData * imaData = [infoDic objectForKey:@"imaData"];
        UIImage * image = [UIImage imageWithData:imaData];
        [button setBackgroundImage:image forState:UIControlStateNormal];
        [self addSubview:button];
        [self bringSubviewToFront:button];
    }
    return self;
}

- (void)buttonAction:(id)sender
{
    [self.delegate expressionButtonAction:self.infoDic];
}

@end
